﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BieuDoGiaVang
{
    public partial class QuanLyGia : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //'STYLE GRIDVIEW
                GridView1.Font.Name = "Arial";
                GridView1.RowStyle.BackColor = System.Drawing.Color.AliceBlue;
                GridView1.AlternatingRowStyle.BackColor = System.Drawing.Color.LightBlue;
                GridView1.GridLines = GridLines.Horizontal;
                GridView1.BorderStyle = BorderStyle.Solid;
                GridView1.BorderColor = System.Drawing.Color.Black;
                GridView1.CellPadding = 5;

                //'STYLE FORMVIEW
                FormView1.Font.Name = "Arial";
                FormView1.CellSpacing = 5;
                FormView1.HeaderStyle.Font.Bold = true;


                FormView1.Visible = CheckVisbleInsert();
            }
        }

        protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
        {
            FormView1.Visible = CheckVisbleInsert();
        }

        private bool CheckVisbleInsert()
        {
            dsGiaVangTableAdapters.VangSJCTableAdapter ad = new dsGiaVangTableAdapters.VangSJCTableAdapter();
            int? soDong = ad.ScalarVangSJCByNgay(DateTime.Now.ToShortDateString());
            if (soDong == null || soDong==0)
            {
               return true;
            }
            else//SoDong>0
            {
               return false;
            }
        }

        protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
        {
            FormView1.Visible = CheckVisbleInsert();
        }
    }
}